20 REM  COMPUTADOR PERSONAL MS-61 ** REVERSO ** version 1.0 **
40 REM Escrito por Marcelo Liberatori para Micro Sistemas S.A. 1984
160 DIM EMPSQ%(55),WHTSQ%(55)
170 DIM BLKSQ%(55),LIN(39)
180 DIM BOARD%(8,8),OLDBOARD%(8,8)
190 DIM XLIST%(60),YLIST%(60)
200 DIM RED%(10),YEL%(10),FIRSTV%(20),FIRSTH%(20)
210 DEF SEG=&H4F:THORIZ=PEEK(0):GVERT=PEEK(1):VERT=PEEK(2):MON=PEEK(3):DISP=PEEK(4)
250 REM Inicializa prioridad, elije lista
260 FOR I%=1 TO 60
270 READ XLIST%(I%),YLIST%(I%)
280 NEXT I%
290 DATA 1,1,1,8,8,1,8,8,1,3,1,6,3,1,3,8,6,1,6,8
300 DATA 8,3,8,6,3,3,3,6,6,3,6,6,1,4,1,5,4,1,8,5
310 DATA 5,1,5,8,8,4,4,8,3,4,3,5,4,3,4,6,5,3,5,6
320 DATA 6,4,6,5,2,4,2,5,4,2,4,7,5,2,5,7,7,4,7,5
330 DATA 2,3,2,6,3,2,3,7,6,2,6,7,7,3,7,6,1,2,1,7
340 DATA 2,1,2,8,7,1,7,8,8,2,8,7,2,2,2,7,7,2,7,7
350 DEF FNHPOS(H)=(H-1)*26+12
360 DEF FNVPOS(V)=(V-1)*20+12
365 IF MON<>1 THEN HW=7:GW=7:YW=7:PAL=1 ELSE HW=15:GW=10:YW=14:PAL=0
370 GOSUB 7010:COLOR HW,0,0:CLS
390 LOCATE 5,8:PRINT"Computador Personal MS-61"
400 COLOR GW,0:LOCATE 9,9:PRINT CHR$(213)+STRING$(21,205)+CHR$(184)
410 LOCATE 10,9:PRINT CHR$(179)+"       REVERSO       "+CHR$(179)
420 LOCATE 11,9:PRINT CHR$(179)+STRING$(21,32)+CHR$(179)
430 LOCATE 12,9:PRINT CHR$(179)+"                     "+CHR$(179)
440 LOCATE 13,9:PRINT CHR$(212)+STRING$(21,205)+CHR$(190)
450 COLOR HW,0:LOCATE 17,5:PRINT"                                   ":LOCATE 19,5:PRINT"                                "
460 COLOR YW,0:LOCATE 22,7:PRINT"Desea leer las instrucciones?"
470 LOCATE 24,7,0:PRINT" Pres. S para si, N para no.";
480 IF INKEY$<>"" GOTO 480' limpia los buffers de las teclas
490 CH$=INKEY$: IF CH$="" GOTO 490
500 IF CH$=CHR$(27) THEN GOSUB 20000:GOTO 470' sale del programa
510 IF CH$="n" OR CH$="N" GOTO 540
520 IF CH$<>"s" AND CH$<>"S" THEN BEEP: GOTO 480
530 GOSUB 4890' Muestro instrucciones
540 GOSUB 580'  Configuro tablero inicial
550 GOTO 950'   Comienza el juego
560 REM
570 REM Dibujo el tablero
580 GOSUB 7110:COLOR 0,PAL: CLS
590 FOR I=10 TO 171 STEP 20
600 LINE (10,I)-(218,I),3
610 NEXT I
620 FOR I=10 TO 219 STEP 26
630 LINE (I,10)-(I,170),3
640 NEXT I
650 PAINT(11,11),1,3
660 GET(12,12)-(34,28),EMPSQ%
670 CIRCLE(23,20),8,3
680 PAINT(23,20),3,3
690 GET(12,12)-(34,28),WHTSQ%
700 CIRCLE(23,20),8,0
710 PAINT(23,20),0,0
720 GET(12,12)-(34,28),BLKSQ%
730 PUT(12,12),EMPSQ%,PSET
740 FOR I%=11 TO 218 STEP 26
750 FOR J%=11 TO 170 STEP 20
760 PAINT(I%,J%),1,3
770 NEXT J%,I%
780 FOR I%=1 TO 8
790 FOR J%=1 TO 8
800 BOARD%(I%,J%)=0
810 NEXT J%,I%
820 SOUNDON%=1: WHITE%=1: BLACK%=2
830 REM
840 REM Coloco la configuracion inicial del tablero
850 REM
860 BOARD%(4,4)=WHITE%: BOARD%(5,5)=WHITE%: BOARD%(4,5)=BLACK%: BOARD%(5,4)=BLACK%
870 PUT(FNHPOS(4),FNVPOS(4)),WHTSQ%,PSET
880 PUT(FNHPOS(5),FNVPOS(4)),BLKSQ%,PSET
890 PUT(FNHPOS(4),FNVPOS(5)),BLKSQ%,PSET
900 PUT(FNHPOS(5),FNVPOS(5)),WHTSQ%,PSET
910 RETURN
920 REM
930 REM START GAME
940 REM
950 WHTCNT%=2: BLKCNT%=2
960 CRSH%=3: CRSV%=4
970 NOWHMV%=0:NOBLMV%=0: HAVECNR%=0
980 LOV%=3: HIV%=6: LOH%=3: HIH%=6
990 MOVCNT%=4
1000 LOCATE 2,29: PRINT"Bienvenido"
1010 LOCATE 3,29: PRINT"Computador"
1020 LOCATE 4,29: PRINT" Personal"
1030 LOCATE 5,30: PRINT"  MS-61"
1040 LOCATE 7,30: PRINT" REVERSO "
1045 IF MON<>1 THEN 1070
1050 GET(12,12)-(19,19),RED%
1060 FOR I%=232 TO 280 STEP 8: GET(I%,48)-(I%+7,55),YEL%: PUT(I%,48),RED%,XOR: PUT(I%,48),YEL%,AND: NEXT I%
1070 LOCATE 9,29: PRINT"Yo tengo ":LOCATE 10,29:PRINT"las fichas ":LOCATE 11,30:PRINT"negras.  "
1080 LOCATE 23,3:PRINT "Desea relizar la 1er movida? S o N";
1090 IF INKEY$<>"" GOTO 1090
1100 CH$=INKEY$: IF CH$="" GOTO 1100
1110 IF CH$="s" OR CH$="S" GOTO 1150
1120 IF CH$=CHR$(27) THEN GOSUB 20000:GOTO 1080
1130 IF CH$<>"n" AND CH$<>"N" THEN BEEP: GOTO 1090
1140 MEFIRST%=1: GOTO 2930
1150 LOCATE 9,29: PRINT "Mueva la X"
1160 LOCATE 10,29: PRINT " con "+CHR$(24)+", "+CHR$(25)+","
1170 LOCATE 11,30: PRINT CHR$(27)+", "+CHR$(26)+", y"
1180 LOCATE 12,30: PRINT "Home, End,"
1190 LOCATE 13,30: PRINT "PgUp, y"
1200 LOCATE 14,30: PRINT "PgDn."
1210 LOCATE 16,30: PRINT "luego pres."
1220 LOCATE 17,30: PRINT "Enter ("+CHR$(27)+" )":DRAW "bm295,131;c3;r5;u3"
1230 LOCATE 18,30: PRINT "p/fijar "
1240 LOCATE 19,30: PRINT "su ficha"
1250 LOCATE 20,30: PRINT "en el    "
1260 LOCATE 21,30: PRINT "tablero. "
1270 FTS%=0
1280 REM
1290 REM Este es el loop principal.
1310 REM
1320 IF MOVCNT%=64 GOTO 4610' fin de juego
1330 IF WHTCNT%=0 GOTO 4570' BLITZ
1350 REM Pregunto por un movimiento del blanco
1370 LOCATE 23,3:PRINT "Es su turno ...                    ";
1380 GOSUB 1720' Pongo X en la pos. del cursor
1390 LOCATE 25,3
1400 PRINT "Su puntaje: ";WHTCNT%;" Mi puntaje: ";BLKCNT%;
1410 PIECE%=WHITE%: SQ%=1
1420 REM Espero un teclazo, y entonces lo analizo.
1440 IF INKEY$<>"" GOTO 1440' limpio buffers
1450 CH$=INKEY$: IF CH$<>"" GOTO 1650
1460 IF SQ%=0 GOTO 1450
1470 POSV%=XLIST%(SQ%):POSH%=YLIST%(SQ%)
1480 GOSUB 3220' Veo si el cuadro es Ok p/el blanco
1490 IF VALUE%<0 GOTO 1650' tecla presionada
1500 IF VALUE%<>0 THEN SQ%=0: GOTO 1450' si valor<>0, el blanco movio.
1510 SQ%=SQ%+1: IF SQ%<61 GOTO 1450
1520 REM Movida invalida para el blanco...
1530 FOR J%=1 TO 3
1540 LOCATE 23,1:PRINT"                                        ";
1550 BEEP:LOCATE 23,3:PRINT"*** No tienes movidas! ***           ";
1560 FOR I%=1 TO 2000
1570 NEXT I%
1580 NEXT J%
1590 IF NOBLMV%=1 GOTO 4610
1600 MSG%=1: NOWHMV%=1
1610 GOTO 2940' turno del negro.
1630 REM Una tecla ha sido presionada
1650 IF LEN(CH$)=2 THEN CH$=RIGHT$(CH$,1): GOTO 1790' Chequeo los cod.Esp.Tec.
1660 IF CH$=CHR$(27) THEN GOSUB 20000:GOTO 1440
1670 IF CH$=CHR$(13) GOTO 2770
1680 BEEP: MSG%=1
1690 LOCATE 23,3
1700 PRINT "Use ESC p/salir, ENTER para mover. ";
1710 GOTO 1420
1720 REM Pongo la X en la pos del cursor.
1730 IF MON=1 THEN 1734
1732 DRAW"bm"+STR$(FNHPOS(CRSH%)+3)+","+STR$(FNVPOS(CRSV%))+";c3;f16;bu16;g16;":GOTO 1740
1734 DRAW"bm"+STR$(FNHPOS(CRSH%)+3)+","+STR$(FNVPOS(CRSV%))+";c2;f16;bu16;g16;"
1740 SOUND 100,1
1750 RETURN
1770 REM Analizo teclas especiales
1790 IF CH$=CHR$(72) GOTO 2060' cursor arriba
1800 IF CH$=CHR$(75) GOTO 2120' cursor a la izq.
1810 IF CH$=CHR$(77) GOTO 2170' cursor a la der.
1820 IF CH$=CHR$(80) GOTO 2220' cursor abajo
1830 IF CH$=CHR$(71) GOTO 2270' cursor arriba e izq.
1840 IF CH$=CHR$(73) GOTO 2320' cursor arriba y der.
1850 IF CH$=CHR$(79) GOTO 2370' cursor abajo e izq.
1860 IF CH$=CHR$(81) GOTO 2420' cursor abajo y der.
1900 GOTO 1680' Mal teclazo
1920 REM Grafico ficha en cuadro corriente
1940 IF MSG%<>1 GOTO 1980
1950 LOCATE 23,1
1960 PRINT "  Es su movida ...                   ";
1970 MSG%=0
1980 IF BOARD%(CRSV%,CRSH%)=WHITE% GOTO 2010
1990 IF BOARD%(CRSV%,CRSH%)=BLACK% GOTO 2020
2000 PUT(FNHPOS(CRSH%),FNVPOS(CRSV%)),EMPSQ%,PSET: RETURN
2010 PUT(FNHPOS(CRSH%),FNVPOS(CRSV%)),WHTSQ%,PSET: RETURN
2020 PUT(FNHPOS(CRSH%),FNVPOS(CRSV%)),BLKSQ%,PSET: RETURN
2040 REM teclas de manejo de cursor
2060 REM hacia arriba
2070 IF CRSV%=1 GOTO 2470' fuera de tablero
2080 GOSUB 1940'Restauro cuadro original
2090 CRSV%=CRSV%-1
2100 GOSUB 1720'Ubico X
2110 GOTO 1420'espero tecla
2120 REM tecla de manejo a la izq
2130 IF CRSH%=1 GOTO 2470' fuera de tablero
2140 GOSUB 1940'Restauro tecla original
2150 CRSH%=CRSH%-1
2160 GOTO 2100' Ubico X
2170 REM Manejo cursor a la der.
2180 IF CRSH%=8 GOTO 2470' fuera de tablero
2190 GOSUB 1940' Restauro cuadro original
2200 CRSH%=CRSH%+1
2210 GOTO 2100' Ubico X
2220 REM Manejo de cursor hacia abajo
2230 IF CRSV%=8 GOTO 2470' fuera de tablero
2240 GOSUB 1940' Restauro cuadro original
2250 CRSV%=CRSV%+1
2260 GOTO 2100' Ubico X
2270 REM A la izq. y arriba
2280 IF CRSV%=1 OR CRSH%=1 GOTO 2470' fuera de tablero
2290 GOSUB 1940' Restauro cuadro
2300 CRSV%=CRSV%-1:CRSH%=CRSH%-1
2310 GOTO 2100' Ubico X
2320 REM Arriba y a la derecha
2330 IF CRSV%=1 OR CRSH%=8 GOTO 2470' fuera de tablero
2340 GOSUB 1940' Restauro cuadro
2350 CRSV%=CRSV%-1:CRSH%=CRSH%+1
2360 GOTO 2100' Ubico X
2370 REM Abajo y a la izq.
2380 IF CRSV%=8 OR CRSH%=1 GOTO 2470' fuera de tablero
2390 GOSUB 1940' Restaura cuadro
2400 CRSV%=CRSV%+1:CRSH%=CRSH%-1
2410 GOTO 2100' Ubico X
2420 REM Abajo y a la der.
2430 IF CRSV%=8 OR CRSH%=8 GOTO 2470' fuera de tablero
2440 GOSUB 1940' Restauro cuadro
2450 CRSV%=CRSV%+1:CRSH%=CRSH%+1
2460 GOTO 2100' Ubico X
2470 REM cuando movio fuera del tablero
2480 LOCATE 23,3: BEEP: MSG%=1
2490 PRINT"La X no puede ir fuera del tablero. "
2500 GOTO 1420
2530 REM   Alt B = Pongo pieza negra en la pos. del cursor
2540 REM   Alt S = Pongo espacio en la pos del cursor
2550 REM   Alt W = Pongo pieza blanca en la pos del cursor
2570 REM Manejo Alt W
2580 IF BOARD%(CRSV%,CRSH%)=BLACK% THEN BLKCNT%=BLKCNT%-1
2590 IF BOARD%(CRSV%,CRSH%)=WHITE% THEN WHTCNT%=WHTCNT%-1
2595 IF BOARD%(CRSV%,CRSH%)=0 THEN MOVCNT%=MOVCNT%+1
2600 BOARD%(CRSV%,CRSH%)=WHITE%
2610 GOSUB 1940: GOSUB 1720
2620 WHTCNT%=WHTCNT%+1
2630 RETURN' Esperando movida
2640 REM Manejo Alt S
2650 IF BOARD%(CRSV%,CRSH%)=BLACK% THEN BLKCNT%=BLKCNT%-1
2660 IF BOARD%(CRSV%,CRSH%)=WHITE% THEN WHTCNT%=WHTCNT%-1
2665 IF BOARD%(CRSV%,CRSH%)<>0 THEN MOVCNT%=MOVCNT%-1
2670 BOARD%(CRSV%,CRSH%)=0
2680 GOSUB 1940: GOSUB 1720
2690 RETURN' Esperando movida
2700 REM Manejo Alt B
2710 IF BOARD%(CRSV%,CRSH%)=WHITE% THEN WHTCNT%=WHTCNT%-1
2720 IF BOARD%(CRSV%,CRSH%)=BLACK% THEN BLKCNT%=BLKCNT%-1
2725 IF BOARD%(CRSV%,CRSH%)=0 THEN MOVCNT%=MOVCNT%+1
2730 BOARD%(CRSV%,CRSH%)=BLACK%
2740 GOSUB 1940: GOSUB 1720
2750 BLKCNT%=BLKCNT%+1
2760 RETURN' Esperando movida
2770 REM
2780 REM examino movida
2800 PIECE%=WHITE%
2810 POSV%=CRSV%: POSH%=CRSH%
2820 GOSUB 3220
2830 IF OK%=1 GOTO 2880
2840 LOCATE 23,3
2850 BEEP: MSG%=1
2860 PRINT "No pude ubicar una pieza blanca ahi.";
2870 GOTO 1420' Espero teclazo
2880 REM
2890 GOSUB 3560' Hago la movida.
2900 LOCATE 25,3:PRINT"Su puntaje: ";WHTCNT%;" Mi puntaje: ";BLKCNT%;
2920 REM Muevo pieza negra (La maquina)
2930 REM
2940 IF MOVCNT%=64 GOTO 4610
2950 LOCATE 23,3:PRINT"Mi movida ...                        ";
2960 IF FTS%=1 GOTO 2980
2970 FTS%=1
2980 IF MEFIRST%=0 THEN LOCATE 2,29:PRINT"           ";
2990 MSG%=0
3000 PIECE%=BLACK%
3010 IF BLKCNT%=0 GOTO 4570' BLITZ
3020 GOSUB 4020
3030 IF TOPVAL%<>0 GOTO 3130'Encuentro movida
3040 LOCATE 23,3:PRINT"*** No tengo movida! ***             ";
3050 BEEP
3060 FOR I%=1 TO 5000: NEXT I%
3070 IF NOWHMV%=1 GOTO 4610' Fin de juego
3080 MSG%=1:NOBLMV%=1
3090 GOTO 1310' Proceso loop principal
3110 REM Una movida para negra ha sido decidida en
3130 REM
3140 GOSUB 3590' hago la movida
3150 LOCATE 25,3
3160 PRINT "Su puntaje: ";WHTCNT%;" Mi puntaje: ";BLKCNT%;
3170 IF MEFIRST% THEN MEFIRST%=0: GOTO 1150
3180 GOTO 1280
3200 REM Veo si el cuadro es Ok p/la movida
3210 REM
3220 OK%=0: VALUE%=0
3230 IF BOARD%(POSV%,POSH%)<>0 THEN RETURN
3240 FOR NEWV%=POSV%-1 TO POSV%+1
3250 FOR NEWH%=POSH%-1 TO POSH%+1
3260 IF SQ%=0 GOTO 3280
3270 CH$=INKEY$: IF CH$<>"" THEN VALUE%=-1: RETURN
3280 IF NEWV%<1 OR NEWV%>8 OR NEWH%<1 OR NEWH%>8 GOTO 3310
3290 IF NEWV%<>POSV% OR NEWH%<>POSH% THEN IF BOARD%(NEWV%,NEWH%)<>0 AND BOARD%(NEWV%,NEWH%)<>PIECE% THEN GOSUB 3480
3300 IF VALUE%<>0 GOTO 3330
3310 NEXT NEWH%,NEWV%
3320 IF VALUE%=0 THEN RETURN
3330 OK%=1: RETURN
3350 REM Computo el numero de piezas que una
3360 REM movida ha capturado.
3370 REM
3380 VALUE%=0: IF BOARD%(POSV%,POSH%)<>0 THEN RETURN' retorno si mov ilegal
3390 FOR NEWV%=POSV%-1 TO POSV%+1: FOR NEWH%=POSH%-1 TO POSH%+1
3400 IF NEWV%<1 OR NEWV%>8 OR NEWH%<1 OR NEWH%>8 GOTO 3420
3410 IF NEWV%<>POSV% OR NEWH%<>POSH% THEN IF BOARD%(NEWV%,NEWH%)<>0 AND BOARD%(NEWV%,NEWH%)<>PIECE% THEN GOSUB 3480
3420 NEXT NEWH%,NEWV%
3430 RETURN
3450 REM veo la posicion indicada, chequeando si
3460 REM alguna pieza ha sido tomada
3480 DELV%=NEWV%-POSV%: DELH%=NEWH%-POSH%
3490 CNT%=1
3500 CHKV%=NEWV%: CHKH%=NEWH%
3510 CHKV%=CHKV%+DELV%: CHKH%=CHKH%+DELH%
3520 IF CHKV%<1 OR CHKV%>8 OR CHKH%<1 OR CHKH%>8 THEN RETURN
3530 IF BOARD%(CHKV%,CHKH%)=0 THEN RETURN
3540 IF BOARD%(CHKV%,CHKH%)<>PIECE% THEN CNT%=CNT%+1: GOTO 3510
3550 VALUE%=VALUE%+CNT%: RETURN
3560 REM
3570 REM Hago la movida a la pos v/h
3590 MOVCNT%=MOVCNT%+1
3600 IF LOV%>1 AND POSV%<=LOV% THEN LOV%=POSV%-1
3610 IF HIV%<8 AND POSV%>=HIV% THEN HIV%=POSV%+1
3620 IF LOH%>1 AND POSH%<=LOH% THEN LOH%=POSH%-1
3630 IF HIH%<8 AND POSH%>=HIH% THEN HIH%=POSH%+1
3640 NOWHMV%=0:NOBLMV%=0
3650 IF PIECE%=WHITE% THEN K%=1 ELSE K%=3
3660 FOR I%=1 TO K%
3670 PUT(FNHPOS(POSH%),FNVPOS(POSV%)),EMPSQ%,PSET
3680 FOR J%=1 TO 50: NEXT J%
3690 PUT(FNHPOS(POSH%),FNVPOS(POSV%)),EMPSQ%,PSET
3700 IF 2*FIX(I%/2)=I% THEN SOUND 200,2 ELSE SOUND 300,2
3710 IF PIECE%=WHITE% THEN PUT(FNHPOS(POSH%),FNVPOS(POSV%)),WHTSQ%,PSET ELSE PUT(FNHPOS(POSH%),FNVPOS(POSV%)),BLKSQ%,PSET
3720 FOR J%=1 TO 50: NEXT J%
3730 NEXT I%
3750 REM Arrojo todas las piezas en las posibles direcciones
3770 IF PIECE%=WHITE% THEN WHTCNT%=WHTCNT%+1 ELSE BLKCNT%=BLKCNT%+1
3780 BOARD%(POSV%,POSH%)=PIECE%'  sumo la pieza en el tablero
3790 MAXVAL%=0
3800 FOR NEWV%=POSV%-1 TO POSV%+1
3810 FOR NEWH%=POSH%-1 TO POSH%+1
3820 VALUE%=0
3830 IF NEWV%<1 OR NEWV%>8 OR NEWH%<1 OR NEWH%>8 GOTO 3960
3840 IF NEWV%<>POSV% OR NEWH%<>POSH% THEN IF BOARD%(NEWV%,NEWH%)<>0 AND BOARD%(NEWV%,NEWH%)<>PIECE% THEN GOSUB 3480
3850 IF VALUE%=0 THEN GOTO 3960
3860 MAXVAL%=MAXVAL%+VALUE%
3870 CHKV%=NEWV%: CHKH%=NEWH%
3880 DELV%=NEWV%-POSV%: DELH%=NEWH%-POSH%
3890 IF SOUNDON% THEN SOUND 600,1
3900 BOARD%(CHKV%,CHKH%)=PIECE%
3910 IF DISPOFF% GOTO 3930
3920 IF PIECE%=WHITE% THEN PUT(FNHPOS(CHKH%),FNVPOS(CHKV%)),WHTSQ%,PSET ELSE PUT(FNHPOS(CHKH%),FNVPOS(CHKV%)),BLKSQ%,PSET
3930 IF PIECE%=WHITE% THEN WHTCNT%=WHTCNT%+1: BLKCNT%=BLKCNT%-1 ELSE BLKCNT%=BLKCNT%+1: WHTCNT%=WHTCNT%-1
3940 CHKV%=CHKV%+DELV%: CHKH%=CHKH%+DELH%
3950 IF BOARD%(CHKV%,CHKH%)<>PIECE% GOTO 3890
3960 NEXT NEWH%,NEWV%
3970 VALUE%=MAXVAL%
3980 RETURN
4000 REM Busco la mejor movida para la maquina
4020 BESTV%=0: BESTH%=0: TOPVAL%=0: SQ%=0
4030 IF MOVCNT%<6 GOTO 4380' Movida aleatoria en el 1er turno
4040 IF MOVCNT%>52 GOTO 4500
4050 FOR SQB%=1 TO 60
4060 POSV%=XLIST%(SQB%): POSH%=YLIST%(SQB%)
4070 GOSUB 3220' Ceo si ese cuadro es Ok para una movida negra.
4080 IF VALUE%=0 GOTO 4350
4090 IF (POSV%=1 AND POSH%=1) OR (POSV%=1 AND POSH%=8) OR (POSV%=8 AND POSH%=1) OR (POSV%=8 AND POSH%=8) THEN HAVECNR%=1
4100 TOPVAL%=VALUE%: BESTV%=POSV%: BESTH%=POSH%
4110 IF HAVECNR% THEN RETURN' no puedo si tienen una esquina.
4120 FOR I%=1 TO 8: FOR J%=1 TO 8: OLDBOARD%(I%,J%)=BOARD%(I%,J%): NEXT J%,I%
4130 OLDWHTCNT%=WHTCNT%: OLDBLKCNT%=BLKCNT%
4140 SOUNDON%=0: DISPOFF%=1: GOSUB 3770
4150 WHVAL%=0: PIECE%=WHITE%: NEWBLKCNT%=BLKCNT%: DISPOFF%=0
4160 IF WHTCNT%=0 GOTO 4270
4170 LOCATE 23,1:PRINT"  .. pensando ..                       ";:MSG%=1
4180 IF LOV%>1 AND BESTV%<=LOV% THEN WHLOV%=BESTV%-1 ELSE WHLOV%=LOV%
4190 IF HIV%<8 AND BESTV%>=HIV% THEN WHHIV%=BESTV%+1 ELSE WHHIV%=HIV%
4200 IF LOH%>1 AND BESTH%<=LOH% THEN WHLOH%=BESTH%-1 ELSE WHLOH%=LOH%
4210 IF HIH%<8 AND BESTH%>=HIH% THEN WHHIH%=BESTH%+1 ELSE WHHIH%=HIH%
4220 FOR POSV%=WHLOV% TO WHHIV%: FOR POSH%=WHLOH% TO WHHIH%
4230 IF BOARD%(POSV%,POSH%)<>0 GOTO 4260
4240 GOSUB 3370
4250 IF VALUE%>WHVAL% THEN WHVAL%=VALUE%
4260 NEXT POSH%,POSV%
4270 FOR I%=1 TO 8: FOR J%=1 TO 8
4280 BOARD%(I%,J%)=OLDBOARD%(I%,J%): NEXT J%,I%
4290 WHTCNT%=OLDWHTCNT%: BLKCNT%=OLDBLKCNT%: PIECE%=BLACK%: SOUNDON%=1
4300 POSV%=BESTV%: POSH%=BESTH%
4310 IF WHVAL%=NEWBLKCNT% THEN GOTO 4340
4320 LOCATE 23,1:PRINT STRING$(40," ");:MSG%=0:RETURN
4330 REM
4340 LOCATE 23,18:PRINT" HMMM - espere un momento";
4350 NEXT SQB%
4360 POSV%=BESTV%: POSH%=BESTH%
4370 RETURN
4380 REM Movida aleatoria para la 1er movida.
4390 FIRSTCNT%=0
4400 FOR POSV%=LOV% TO HIV%: FOR POSH%=LOH% TO HIH%
4410 IF BOARD%(POSV%,POSH%)<>0 GOTO 4440
4420 GOSUB 3220
4430 IF VALUE%>0 THEN FIRSTCNT%=FIRSTCNT%+1: FIRSTV%(FIRSTCNT%)=POSV%: FIRSTH%(FIRSTCNT%)=POSH%
4440 NEXT POSH%,POSV%
4450 RANDOMIZE PEEK(&H46C)
4460 I%=1+FIX(FIRSTCNT%*RND)
4470 POSH%=FIRSTH%(I%): POSV%=FIRSTV%(I%): TOPVAL%=1
4480 RETURN
4485 REM
4500 FOR POSV%=1 TO 8: FOR POSH%=1 TO 8
4510 IF BOARD%(POSV%,POSH%)<>0 GOTO 4540
4520 GOSUB 3370
4530 IF VALUE%>TOPVAL% THEN BESTV%=POSV%: BESTH%=POSH%: TOPVAL%=VALUE%
4540 NEXT POSH%,POSV%
4550 POSH%=BESTH%: POSV%=BESTV%: RETURN
4560 REM
4570 LOCATE 24,3:PRINT"MUY BUENO !! ";
4590 REM Fin de juego ... veo puntajes.
4610 IF WHTCNT%>BLKCNT% GOTO 4650
4620 IF WHTCNT%<BLKCNT% GOTO 4690
4630 LOCATE 23,3:PRINT"Es un empate!  ";
4640 GOTO 4700
4650 LOCATE 23,3:PRINT"Tu ganas!               ";
4660 S1$="O2L8DGBO3DP8O2BO3D1"
4670 PLAY "T210XS1$;"
4680 GOTO 4700
4690 LOCATE 23,3:PRINT"Yo gano!!!!  ";
4700 REM
4710 LOCATE 23,15:PRINT"Pres. Esc p/salir, o  ";
4720 LOCATE 24,15:PRINT"Espacio p/jugar de nuevo.";
4730 SOUND 400,1: SOUND 800,1
4740 SOUND 500,1: SOUND 900,1
4750 IF INKEY$<>"" GOTO 4750
4760 CH$=INKEY$: IF CH$="" GOTO 4760
4770 IF CH$=CHR$(27) THEN GOSUB 20000:GOTO 4720
4780 IF CH$<>" " THEN BEEP: GOTO 4750 ELSE LOCATE 23,3: PRINT STRING$(37," "):LOCATE 24,12:PRINT STRING$(23," "): GOTO 540' Restaura el juego
4890 REM
4900 REM Reglas del REVERSO
4910 REM
4920 GOSUB 580'Muestra el tablero
4930 LOCATE 3,29: PRINT"Este es el ";
4940 LOCATE 4,29: PRINT"tablero ori";
4950 LOCATE 5,29: PRINT"ginal. Sus ";
4960 LOCATE 6,29: PRINT"fichas son ";
4970 LOCATE 7,29: PRINT"blancas. El";
4980 LOCATE 8,29: PRINT"objeto es  ";
4990 LOCATE 9,29:PRINT"tomar la ma-";
5000 LOCATE 10,29:PRINT"yor cantidad";
5010 LOCATE 11,29:PRINT"de fichas de";
5020 LOCATE 12,29:PRINT"su color.";
5030 LOCATE 14,29:PRINT"En cada    ";
5040 LOCATE 15,29:PRINT"turno, un  ";
5050 LOCATE 16,29:PRINT"jug. puede ";
5060 LOCATE 17,29:PRINT"poner una  ";
5070 LOCATE 18,29:PRINT"ficha de su";
5080 LOCATE 19,29:PRINT"color en el";
5090 LOCATE 20,29:PRINT"tablero.   ";
5100 LOCATE 23,3:PRINT"Se termina cuando se llena el tablero";
5110 LOCATE 25,3: PRINT"   PRES. ESPACIO PARA CONTINUAR ";
5120 GOSUB 6640
5130 LOCATE 3,29: PRINT"Solo se    ";
5140 LOCATE 4,29: PRINT"pueden ubi-";
5150 LOCATE 5,29: PRINT"car fichas,";
5160 LOCATE 6,29: PRINT"donde se   ";
5170 LOCATE 7,29: PRINT"puedan cap-";
5180 LOCATE 8,29: PRINT"turar 1 o   ";
5190 LOCATE 9,29: PRINT"mas fichas  ";
5200 LOCATE 10,29:PRINT"del rival.  ";
5210 LOCATE 11,29:PRINT"            ";
5220 LOCATE 12,29:PRINT"            ";
5230 LOCATE 13,29:PRINT"Cuando     ";
5240 LOCATE 14,29:PRINT"capture una";
5250 LOCATE 15,29:PRINT"ficha, ella";
5260 LOCATE 16,29:PRINT"tomara su  ";
5270 LOCATE 17,29:PRINT"color y en-";
5280 LOCATE 18,29:PRINT"tonces ya  ";
5290 LOCATE 19,29:PRINT"sera suya. ";
5300 LOCATE 20,29:PRINT"           ";
5310 LOCATE 21,29:PRINT"           ";
5320 LOCATE 23,3: PRINT"Ambos comenzamos con 2 fichas.       ";
5330 GOSUB 6640
5340 LOCATE 3,29: PRINT"Para tomar ";
5350 LOCATE 4,29: PRINT"una ficha, ";
5360 LOCATE 5,29: PRINT"debe ence- ";
5370 LOCATE 6,29: PRINT"rrarla entre";
5380 LOCATE 7,29: PRINT"dos suyas. ";
5390 LOCATE 8,29: PRINT"           ";
5400 CRSH%=5:CRSV%=3:GOSUB 1720
5410 CRSH%=6:CRSV%=4:GOSUB 1720
5420 CRSH%=3:CRSV%=5:GOSUB 1720
5430 CRSH%=4:CRSV%=6:GOSUB 1720
5440 LOCATE 9,29: PRINT"La 'X' esta";
5450 LOCATE 10,29:PRINT"en el cuadro";
5460 LOCATE 11,29:PRINT"donde movio";
5470 LOCATE 12,29:PRINT"en el turno";
5480 LOCATE 13,29:PRINT"anterior. ";
5490 LOCATE 14,29:PRINT"           ";
5500 LOCATE 15,29:PRINT"           ";
5510 LOCATE 16,29:PRINT"           ";
5520 LOCATE 17,29:PRINT"Cada X     ";
5530 LOCATE 18,29:PRINT"encierra   ";
5540 LOCATE 19,29:PRINT"una negra  ";
5550 LOCATE 20,29:PRINT"en alguna  ";
5560 LOCATE 21,29:PRINT"linea.     ";
5570 LOCATE 23,3: PRINT"Blanca-Negra-Blanca es un encierro. ";
5580 GOSUB 6640
5590 LOCATE 3,29: PRINT"Suponga que";
5600 LOCATE 4,29: PRINT"mueve donde";
5610 LOCATE 5,29: PRINT"la X esta  ";
5620 LOCATE 6,29: PRINT"ahora. Esta ";
5630 LOCATE 7,29: PRINT"movida cap-";
5640 LOCATE 8,29: PRINT"turara la  ";
5650 LOCATE 9,29: PRINT"negra que  ";
5660 LOCATE 10,29:PRINT"esta abajo. ";
5670 LOCATE 11,29:PRINT"           ";
5680 CRSH%=6:CRSV%=4:GOSUB 1940
5690 CRSH%=3:CRSV%=5:GOSUB 1940
5700 CRSH%=4:CRSV%=6:GOSUB 1940
5710 LOCATE 12,29:PRINT"Cuando esta";
5720 LOCATE 13,29:PRINT"movida es  ";
5730 LOCATE 14,29:PRINT"hecha, la  ";
5740 LOCATE 15,29:PRINT"X sera re- ";
5750 LOCATE 16,29:PRINT"emplazada  ";
5760 LOCATE 17,29:PRINT"por, ficha ";
5770 LOCATE 18,29:PRINT"blanca, y  ";
5780 LOCATE 19,29:PRINT"la negra   ";
5790 LOCATE 20,29:PRINT"se pondra  ";
5800 LOCATE 21,29:PRINT"blanca.    ";
5810 LOCATE 23,3: PRINT"El puntaje sera 4 Blancas a 1 negra.  ";
5820 GOSUB 6640
5830 PIECE%=WHITE%:POSH%=5:POSV%=3:GOSUB 3560
5840 LOCATE 3,29: PRINT"El tablero ";
5850 LOCATE 4,29: PRINT"muestra    ";
5860 LOCATE 5,29: PRINT"ahora eso. ";
5870 LOCATE 6,29: PRINT"            ";
5880 LOCATE 7,29: PRINT"Es ahora el";
5890 LOCATE 8,29: PRINT"turno de la";
5900 LOCATE 9,29: PRINT"negra...   ";
5910 LOCATE 10,29:PRINT"            ";
5920 LOCATE 11,29:PRINT"La 'X' mues-";
5930 LOCATE 12,29:PRINT"tra donde  ";
5940 LOCATE 13,29:PRINT"puede jugar";
5950 LOCATE 14,29:PRINT"una ficha  ";
5960 LOCATE 15,29:PRINT"negra.     ";
5970 LOCATE 16,29:PRINT"           ";
5980 CRSH%=4:CRSV%=3:GOSUB 1720
5990 CRSH%=6:CRSV%=3:GOSUB 1720
6000 CRSH%=6:CRSV%=5:GOSUB 1720
6010 LOCATE 17,29:PRINT"La captura ";
6020 LOCATE 18,29:PRINT"puede ser  ";
6030 LOCATE 19,29:PRINT"en diagonal";
6040 LOCATE 20,29:PRINT"tambien.   ";
6050 LOCATE 21,29:PRINT"           ";
6060 LOCATE 23,3: PRINT"Una mov. puede ir en varias direc.   ";
6070 GOSUB 6640
6080 CRSH%=4:CRSV%=3:BOARD%(3,4)=WHITE%:GOSUB 1940'blanca
6090 CRSH%=5:BOARD%(3,5)=WHITE%: GOSUB 1940' blanca
6100 CRSH%=6:BOARD%(3,6)=WHITE%: GOSUB 1940' blanca
6110 CRSH%=7:BOARD%(3,7)=WHITE%: GOSUB 1940' blanca
6120 CRSH%=4:CRSV%=4:BOARD%(4,4)=BLACK%:GOSUB 1940'negra
6130 CRSH%=5:BOARD%(4,5)=BLACK%: GOSUB 1940' negra
6140 CRSH%=6:BOARD%(4,6)=BLACK%: GOSUB 1940' negra
6150 CRSH%=4:CRSV%=5:BOARD%(5,4)=BLACK%:GOSUB 1940'negra
6160 CRSH%=5:BOARD%(5,5)=BLACK%: GOSUB 1940' negra
6170 CRSH%=6:BOARD%(5,6)=BLACK%: GOSUB 1940' negra
6180 CRSH%=4:CRSV%=6:GOSUB 1720' X
6190 LOCATE 3,29: PRINT"En este e- ";
6200 LOCATE 4,29: PRINT"jemplo, una";
6210 LOCATE 5,29: PRINT"ficha blanca";
6220 LOCATE 6,29: PRINT"mov. sobre  ";
6230 LOCATE 7,29: PRINT"La X tomara";
6240 LOCATE 8,29: PRINT"4 negras; 2";
6250 LOCATE 9,29: PRINT"arriba, y 2";
6260 LOCATE 10,29:PRINT"en diagonal";
6270 LOCATE 11,29:PRINT"a la dere-  ";
6280 LOCATE 12,29:PRINT"cha.       ";
6290 LOCATE 13,29:PRINT"           ";
6300 LOCATE 14,29:PRINT"           ";
6310 LOCATE 15,29:PRINT"           ";
6320 LOCATE 16,29:PRINT"Una sola   ";
6330 LOCATE 17,29:PRINT"movida pue-";
6340 LOCATE 18,29:PRINT"de capturar";
6350 LOCATE 19,29:PRINT"en cualquier";
6360 LOCATE 20,29:PRINT"direccion!!";
6370 LOCATE 21,29:PRINT"           ";
6380 LOCATE 23,3:PRINT"                                       ";
6390 GOSUB 6640
6400 POSH%=4:POSV%=6:GOSUB 3560' Haga la movida
6410 LOCATE 3,29: PRINT"Las fichas ";
6420 LOCATE 4,29: PRINT"en el borde";
6430 LOCATE 5,29: PRINT"del tablero ";
6440 LOCATE 6,29: PRINT"son duras   ";
6450 LOCATE 7,29: PRINT"de tomar.  ";
6460 LOCATE 8,29: PRINT"           ";
6470 LOCATE 9,29: PRINT"Las fichas ";
6480 LOCATE 10,29:PRINT"en las es-  ";
6490 LOCATE 11,29:PRINT"quinas no   ";
6500 LOCATE 12,29:PRINT"pueden ser ";
6510 LOCATE 13,29:PRINT"capturadas.";
6520 LOCATE 14,29:PRINT"           ";
6530 LOCATE 15,29:PRINT"Las reglas ";
6540 LOCATE 16,29:PRINT"son simples";
6550 LOCATE 17,29:PRINT"pero no asi";
6560 LOCATE 18,29:PRINT"la estrate-";
6570 LOCATE 19,29:PRINT"gia...      ";
6580 LOCATE 20,29:PRINT"           ";
6590 LOCATE 21,29:PRINT"SUERTE !!! ";
6600 LOCATE 23,3:PRINT"Para salir, pres. ESC cuando quiera.";
6610 LOCATE 25,5:PRINT"PRES. ESPACIO PARA COMENZAR      ";
6620 GOSUB 6640
6630 RETURN
6640 CH$=INKEY$:IF CH$<>"" GOTO 6640
6645 CH$=INKEY$:IF CH$="" GOTO 6645
6650 IF CH$=CHR$(27) THEN GOSUB 20000:GOTO 6640
6660 IF CH$=" " THEN RETURN
6670 SOUND 400,4
6680 IF INKEY$<>"" GOTO 6680
6690 GOTO 6645
7000 REM ********** PONGO DISPLAY EN MODO TEXTO 40x25  *********
7010 SCREEN 0,1,0,0
7020 OUT 980,2:OUT 981,THORIZ
7030 OUT 980,7:OUT 981,VERT
7040 RETURN
7100 REM ********** PONGO DISPLAY EN MODO GRAFICO 40x25  *********
7110 SCREEN 1,0,0,0
7120 OUT 980,2:OUT 981,THORIZ
7130 OUT 980,7:OUT 981,GVERT
7140 RETURN
20000 SOUND 400,4:FOR I=1 TO 39:LIN(I)=SCREEN(25,I):NEXT
20010 LOCATE 25,1:PRINT "Esta sequro de querer  salir (S/N)?";
20020 A$=INKEY$:IF A$<>"" THEN 20020
20030 A$=INKEY$:IF A$="" THEN 20030
20040 IF A$="s" OR A$="S" THEN 21000
20050 IF A$<>"N" AND A$<>"n" THEN SOUND 400,4:GOTO 20030
20060 LOCATE 25,1:FOR I=1 TO 39:PRINT CHR$(LIN(I));:NEXT
20070 RETURN
21000 CLS:LOCATE 12,14:PRINT "Cargando Menu..."
21010 CHAIN "menu"
